package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetMealService;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: sky-take-out
 * @description:
 * @author: fmp
 * @create: 2023-04-09 15:10
 * @Version 1.0
 **/
@Slf4j
@RestController
@Api(tags = "套餐相关接口")
@RequestMapping("/admin/setmeal")
public class SetMealController {
        @Resource
        private SetMealService setMealService;
        //新增套餐
        @PostMapping
        @ApiOperation(value = "新增套餐")
        public Result InsertSetMeal(@RequestBody SetmealDTO setmealDTO){
            setMealService.InsertSetMeal(setmealDTO);
            return Result.success();
        }
        //分页查询
    @GetMapping("/page")
    @ApiOperation("分页查询")
    public Result SelectPageQuery(SetmealPageQueryDTO setmealPageQueryDTO){
        PageResult result = setMealService.SelectPageQuery(setmealPageQueryDTO);
        return Result.success(result);
    }
    //修改状态
    @PostMapping("/status/{status}")
    @ApiOperation("修改出售状态")
    public Result updateStatus(@PathVariable Integer status,Long id){

            setMealService.updateStatus(status,id);
            return Result.success();
    }
    //修改套餐信息
    @PutMapping
    @ApiOperation("修改套餐信息")
    public Result UpdateSetmeal(@RequestBody SetmealDTO setmealDTO) {
        setMealService.updateSetmeal(setmealDTO);
        return Result.success();
    }
    //删除套餐信息
    @DeleteMapping
    @ApiOperation("删除套餐信息")
    public Result deleteSetMealById(@RequestParam List<Long> ids){
            setMealService.deleteSetMealById(ids);
            return Result.success();
    }
    //根据id查询
    @GetMapping("/{setmealId}")
    @ApiOperation("根据setmealid查询")
    public Result selectBYDishId(@PathVariable Long setmealId){
            SetmealVO setmealVO = setMealService.selectByDishId(setmealId);
            return Result.success(setmealVO);
    }


}
